import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { NewsService } from '../../service/news.service';
import { News } from '../../domain/news';
import { Toastr } from '../../common/toastr';

@Component({
    moduleId: module.id,
    templateUrl: 'newsInfo.component.html'
})
export class NewsInfoComponent implements OnInit {
    private title: string = "新闻详情";
    private subTitle: string = "查看新闻详情";
    private news: News = new News();
    constructor(
        private route: ActivatedRoute,
        private newsSvr: NewsService,
    ) {

    }

    async ngOnInit() {
        try {
            let id = +this.route.snapshot.params['id'];
            if (id)
                this.news = await this.newsSvr.GetNewsInfo(id);
        } catch (error) {
            Toastr.Error(error);
        }
    }
}